package com.jjwt.demo;

import java.util.Scanner;

public class ListDemo3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
//1、定义字符串
        String string = scanner.next();
//2.定义变量用于判断是否是回文字符串
        boolean flag = true;
//3.循环判断看是否是回文字符串
        for(int i = 0,len = string.length();i < len/2;i++){
            char c = string.charAt(i);
            char c1 = string.charAt(len - 1 - i);
            System.out.println(c+"   "+c1);
            if(c!=c1){
                flag=false;
            }
        }

        //4.再根据flag的值决定是否是回文字符串
        if(flag){
            System.out.println(string + "是一个回文字符串！");
        }else{
            System.out.println(string + "不是一个回文字符串！");
        }
//5.关闭scanner
        scanner.close();
    }

}
